﻿using JetBrains.DocumentModel;
using JetBrains.ReSharper.Feature.Services.Daemon;
using JetBrains.ReSharper.Psi.Tree;

namespace ReSharePoint.Basic.Inspection.Common.CodeAnalysis
{
    public abstract class SPCSharpErrorHighlighting<TElement> : ISPHighlighting<TElement>, IHighlighting
        where TElement : ITreeNode
    {
        private readonly string _toolTip;
        public TElement Element { get; set; }

        public SPCSharpErrorHighlighting(TElement element, string toolTip)
        {
            _toolTip = toolTip;
            Element = element;
        }

        #region IHighlighting Members
        public DocumentRange CalculateRange()
        {
            return Element.GetNavigationRange();
        }
        public string ToolTip
        {
            get
            {
                return _toolTip;
            }
        }
        public string ErrorStripeToolTip
        {
            get { return ToolTip; }
        }

        public int NavigationOffsetPatch
        {
            get { return 0; }
        }

        public bool IsValid()
        {
            return Element != null && Element.IsValid();
        }

        #endregion
    }
}
